##rm(list = ls()) 

# # Set the working directory to the location of the current script
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))  # Set working directory to the current script's directory
getwd()  # Check the current working directory

# load in file when it isnt in the environment already
load("FLVoterFile2012Clean.RData")
load("FLVoterFile2014Clean.RData")
load("FLVoterFile2016Clean.RData")
load("FLVoterFile2019Clean.RData")

FLVoterFile2016 = FLVoterFile2016clean
rm(FLVoterFile2016clean)

##### 2012 Recoding #####

# Gender: 1 = male, 0 = female or other (which likely includes some men)
FLVoterFile2012$gender2 <- with(FLVoterFile2012, ifelse(Gender == "M", 1, 0))
FLVoterFile2012$gender2 [which (is.na (FLVoterFile2012$gender2))] <- 0 

# Party Dummies
FLVoterFile2012$Rep <- with(FLVoterFile2012, ifelse(PartyAffiliation == "REP", 1, 0))
FLVoterFile2012$Dem <- with(FLVoterFile2012, ifelse(PartyAffiliation == "DEM", 1, 0))
FLVoterFile2012$NPA <- with(FLVoterFile2012, ifelse(PartyAffiliation == "NPA", 1, 0))
FLVoterFile2012$Third <- with(FLVoterFile2012, ifelse(PartyAffiliation == "Other", 1, 0))


# Age categories: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
FLVoterFile2012$AgeCat2012 <- with(FLVoterFile2012, ifelse(Age <= 29, 1,
                                                           ifelse(Age <= 44, 2, 
                                                                  ifelse(Age <= 64, 3, 
                                                                         ifelse(Age > 64, 4, 0)))))
FLVoterFile2012$AgeCat2012 <- factor(FLVoterFile2012$AgeCat2012)


# Race Dummies: 
FLVoterFile2012$Other <- with(FLVoterFile2012, ifelse(RaceAdjusted == 0, 1, 0))
FLVoterFile2012$Black <- with(FLVoterFile2012, ifelse(RaceAdjusted == 1, 1, 0))
FLVoterFile2012$Hispanic <- with(FLVoterFile2012, ifelse(RaceAdjusted == 2, 1, 0))
FLVoterFile2012$White <- with(FLVoterFile2012, ifelse(RaceAdjusted == 3, 1, 0))


# # Round age variable to full number
FLVoterFile2012$Age <- lapply(FLVoterFile2012$Age, as.integer)
# 


save(FLVoterFile2012, file = "FLVoterFile2012Final.RData")


##### 2014 Recoding #####

# Gender: 1 = male, 0 = female or other (which likely includes some men)
FLVoterFile2014$gender2 <- with(FLVoterFile2014, ifelse(Gender == "M", 1, 0))
FLVoterFile2014$gender2 [which (is.na (FLVoterFile2014$gender2))] <- 0 

# Party Dummies
FLVoterFile2014$Rep <- with(FLVoterFile2014, ifelse(PartyAffiliation == "REP", 1, 0))
FLVoterFile2014$Dem <- with(FLVoterFile2014, ifelse(PartyAffiliation == "DEM", 1, 0))
FLVoterFile2014$NPA <- with(FLVoterFile2014, ifelse(PartyAffiliation == "NPA", 1, 0))
FLVoterFile2014$Third <- with(FLVoterFile2014, ifelse(PartyAffiliation == "Other", 1, 0))


# Age categories: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
FLVoterFile2014$AgeCat2014 <- with(FLVoterFile2014, ifelse(Age <= 29, 1,
                                                           ifelse(Age <= 44, 2, 
                                                                  ifelse(Age <= 64, 3, 
                                                                         ifelse(Age > 64, 4, 0)))))
FLVoterFile2014$AgeCat2014 <- factor(FLVoterFile2014$AgeCat2014)


# Race Dummies: 
FLVoterFile2014$Other <- with(FLVoterFile2014, ifelse(RaceAdjusted == 0, 1, 0))
FLVoterFile2014$Black <- with(FLVoterFile2014, ifelse(RaceAdjusted == 1, 1, 0))
FLVoterFile2014$Hispanic <- with(FLVoterFile2014, ifelse(RaceAdjusted == 2, 1, 0))
FLVoterFile2014$White <- with(FLVoterFile2014, ifelse(RaceAdjusted == 3, 1, 0))


# # Round age variable to full number
FLVoterFile2014$Age <- lapply(FLVoterFile2014$Age, as.integer)
# 


save(FLVoterFile2014, file = "FLVoterFile2014Final.RData")


##### 2016 Recoding #####

# Gender: 1 = male, 0 = female or other (which likely includes some men)
FLVoterFile2016$gender2 <- with(FLVoterFile2016, ifelse(Gender == "M", 1, 0))
FLVoterFile2016$gender2 [which (is.na (FLVoterFile2016$gender2))] <- 0 

# Party Dummies
FLVoterFile2016$Rep <- with(FLVoterFile2016, ifelse(PartyAffiliation == "REP", 1, 0))
FLVoterFile2016$Dem <- with(FLVoterFile2016, ifelse(PartyAffiliation == "DEM", 1, 0))
FLVoterFile2016$NPA <- with(FLVoterFile2016, ifelse(PartyAffiliation == "NPA", 1, 0))
FLVoterFile2016$Third <- with(FLVoterFile2016, ifelse(PartyAffiliation == "Other", 1, 0))


# Age categories: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
FLVoterFile2016$AgeCat2016 <- with(FLVoterFile2016, ifelse(Age <= 29, 1,
                                                           ifelse(Age <= 44, 2, 
                                                                  ifelse(Age <= 64, 3, 
                                                                         ifelse(Age > 64, 4, 0)))))
FLVoterFile2016$AgeCat2016 <- factor(FLVoterFile2016$AgeCat2016)


# Race Dummies: 
FLVoterFile2016$Other <- with(FLVoterFile2016, ifelse(RaceAdjusted == 0, 1, 0))
FLVoterFile2016$Black <- with(FLVoterFile2016, ifelse(RaceAdjusted == 1, 1, 0))
FLVoterFile2016$Hispanic <- with(FLVoterFile2016, ifelse(RaceAdjusted == 2, 1, 0))
FLVoterFile2016$White <- with(FLVoterFile2016, ifelse(RaceAdjusted == 3, 1, 0))


# # Round age variable to full number
FLVoterFile2016$Age <- lapply(FLVoterFile2016$Age, as.integer)
# 


save(FLVoterFile2016, file = "FLVoterFile2016Final.RData")


##### 2018 Recoding #####

# Gender: 1 = male, 0 = female or other (which likely includes some men)
FLVoterFile2019$gender2 <- with(FLVoterFile2019, ifelse(Gender == "M", 1, 0))
FLVoterFile2019$gender2 [which (is.na (FLVoterFile2019$gender2))] <- 0 

# Party Dummies
FLVoterFile2019$Rep <- with(FLVoterFile2019, ifelse(PartyAffiliation == "REP", 1, 0))
FLVoterFile2019$Dem <- with(FLVoterFile2019, ifelse(PartyAffiliation == "DEM", 1, 0))
FLVoterFile2019$NPA <- with(FLVoterFile2019, ifelse(PartyAffiliation == "NPA", 1, 0))
FLVoterFile2019$Third <- with(FLVoterFile2019, ifelse(PartyAffiliation == "Other", 1, 0))


# Age categories: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
FLVoterFile2019$AgeCat2019 <- with(FLVoterFile2019, ifelse(Age <= 29, 1,
                                                           ifelse(Age <= 44, 2, 
                                                                  ifelse(Age <= 64, 3, 
                                                                         ifelse(Age > 64, 4, 0)))))
FLVoterFile2019$AgeCat2019 <- factor(FLVoterFile2019$AgeCat2019)


# Race Dummies: 
FLVoterFile2019$Other <- with(FLVoterFile2019, ifelse(RaceAdjusted == 0, 1, 0))
FLVoterFile2019$Black <- with(FLVoterFile2019, ifelse(RaceAdjusted == 1, 1, 0))
FLVoterFile2019$Hispanic <- with(FLVoterFile2019, ifelse(RaceAdjusted == 2, 1, 0))
FLVoterFile2019$White <- with(FLVoterFile2019, ifelse(RaceAdjusted == 3, 1, 0))


# # Round age variable to full number
FLVoterFile2019$Age <- lapply(FLVoterFile2019$Age, as.integer)
# 


save(FLVoterFile2019, file = "FLVoterFile2019Final.RData")


#========================#
# RELIEF Voter File 2012 #  
#========================#
# # select only the needed variables

ReliefVoterFile2012 <- subset(FLVoterFile2012, FLVoterFile2012$CountyCode=="BAY" | FLVoterFile2012$CountyCode=="FRA" | FLVoterFile2012$CountyCode=="GUL" 
                                | FLVoterFile2012$CountyCode=="JAC" | FLVoterFile2012$CountyCode=="HOL" | FLVoterFile2012$CountyCode=="WAK" 
                                | FLVoterFile2012$CountyCode=="WAS" | FLVoterFile2012$CountyCode=="CAL" | FLVoterFile2012$CountyCode=="GAD"  
                                | FLVoterFile2012$CountyCode=="LEO" | FLVoterFile2012$CountyCode=="LIB" | FLVoterFile2012$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ReliefRaceTable2012 = table(ReliefVoterFile2012$RaceAdjusted)/nrow(ReliefVoterFile2012)

# GENDER: 0 = Female or other, 1 = Male
ReliefGenderTable2012 = table(ReliefVoterFile2012$gender2)/nrow(ReliefVoterFile2012)

# PARTY
ReliefPartyTable2012 = table(ReliefVoterFile2012$PartyAffiliation)/nrow(ReliefVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ReliefAgeTable2012 = table(ReliefVoterFile2012$AgeCat2012)/nrow(ReliefVoterFile2012)

##Treatment Counties##
TreatmentCounties2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="BAY" | ReliefVoterFile2012$CountyCode=="FRA" 
                                | ReliefVoterFile2012$CountyCode=="GUL" | ReliefVoterFile2012$CountyCode=="JAC"
                                | ReliefVoterFile2012$CountyCode=="WAS" | ReliefVoterFile2012$CountyCode=="CAL" 
                                | ReliefVoterFile2012$CountyCode=="GAD" | ReliefVoterFile2012$CountyCode=="LIB")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
TreatmentRaceTable2012 = table(TreatmentCounties2012$RaceAdjusted)/nrow(TreatmentCounties2012)

# GENDER: 0 = Female or other, 1 = Male
TreatmentGenderTable2012 = table(TreatmentCounties2012$gender2)/nrow(TreatmentCounties2012)

# PARTY
TreatmentPartyTable2012 = table(TreatmentCounties2012$PartyAffiliation)/nrow(TreatmentCounties2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
TreatmentAgeTable2012 = table(TreatmentCounties2012$AgeCat2012)/nrow(TreatmentCounties2012)

##Control Counties##
ControlCounties2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="WAK" | ReliefVoterFile2012$CountyCode=="LEO" 
                              | ReliefVoterFile2012$CountyCode=="HOL" | ReliefVoterFile2012$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ControlRaceTable2012 = table(ControlCounties2012$RaceAdjusted)/nrow(ControlCounties2012)

# GENDER: 0 = Female or other, 1 = Male
ControlGenderTable2012 = table(ControlCounties2012$gender2)/nrow(ControlCounties2012)

# PARTY
ControlPartyTable2012 = table(ControlCounties2012$PartyAffiliation)/nrow(ControlCounties2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ControlAgeTable2012 = table(ControlCounties2012$AgeCat2012)/nrow(ControlCounties2012)

#========================#
# RELIEF Voter File 2014 #  
#========================#
# # select only the needed variables

ReliefVoterFile2014 <- subset(FLVoterFile2014, FLVoterFile2014$CountyCode=="BAY" | FLVoterFile2014$CountyCode=="FRA" | FLVoterFile2014$CountyCode=="GUL" 
                              | FLVoterFile2014$CountyCode=="JAC" | FLVoterFile2014$CountyCode=="HOL" | FLVoterFile2014$CountyCode=="WAK" 
                              | FLVoterFile2014$CountyCode=="WAS" | FLVoterFile2014$CountyCode=="CAL" | FLVoterFile2014$CountyCode=="GAD"  
                              | FLVoterFile2014$CountyCode=="LEO" | FLVoterFile2014$CountyCode=="LIB" | FLVoterFile2014$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ReliefRaceTable2014 = table(ReliefVoterFile2014$RaceAdjusted)/nrow(ReliefVoterFile2014)

# GENDER: 0 = Female or other, 1 = Male
ReliefGenderTable2014 = table(ReliefVoterFile2014$gender2)/nrow(ReliefVoterFile2014)

# PARTY
ReliefPartyTable2014 = table(ReliefVoterFile2014$PartyAffiliation)/nrow(ReliefVoterFile2014)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ReliefAgeTable2014 = table(ReliefVoterFile2014$AgeCat2014)/nrow(ReliefVoterFile2014)

##Treatment Counties##
TreatmentCounties2014 <- subset(ReliefVoterFile2014, ReliefVoterFile2014$CountyCode=="BAY" | ReliefVoterFile2014$CountyCode=="FRA" 
                                | ReliefVoterFile2014$CountyCode=="GUL" | ReliefVoterFile2014$CountyCode=="JAC"
                                | ReliefVoterFile2014$CountyCode=="WAS" | ReliefVoterFile2014$CountyCode=="CAL" 
                                | ReliefVoterFile2014$CountyCode=="GAD" | ReliefVoterFile2014$CountyCode=="LIB")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
TreatmentRaceTable2014 = table(TreatmentCounties2014$RaceAdjusted)/nrow(TreatmentCounties2014)

# GENDER: 0 = Female or other, 1 = Male
TreatmentGenderTable2014 = table(TreatmentCounties2014$gender2)/nrow(TreatmentCounties2014)

# PARTY
TreatmentPartyTable2014 = table(TreatmentCounties2014$PartyAffiliation)/nrow(TreatmentCounties2014)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
TreatmentAgeTable2014 = table(TreatmentCounties2014$AgeCat2014)/nrow(TreatmentCounties2014)

##Control Counties##
ControlCounties2014 <- subset(ReliefVoterFile2014, ReliefVoterFile2014$CountyCode=="WAK" | ReliefVoterFile2014$CountyCode=="LEO" 
                              | ReliefVoterFile2014$CountyCode=="HOL" | ReliefVoterFile2014$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ControlRaceTable2014 = table(ControlCounties2014$RaceAdjusted)/nrow(ControlCounties2014)

# GENDER: 0 = Female or other, 1 = Male
ControlGenderTable2014 = table(ControlCounties2014$gender2)/nrow(ControlCounties2014)

# PARTY
ControlPartyTable2014 = table(ControlCounties2014$PartyAffiliation)/nrow(ControlCounties2014)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ControlAgeTable2014 = table(ControlCounties2014$AgeCat2014)/nrow(ControlCounties2014)

#========================#
# RELIEF Voter File 2016 #  
#========================#
# # select only the needed variables

ReliefVoterFile2016 <- subset(FLVoterFile2016, FLVoterFile2016$CountyCode=="BAY" | FLVoterFile2016$CountyCode=="FRA" | FLVoterFile2016$CountyCode=="GUL" 
                              | FLVoterFile2016$CountyCode=="JAC" | FLVoterFile2016$CountyCode=="HOL" | FLVoterFile2016$CountyCode=="WAK" 
                              | FLVoterFile2016$CountyCode=="WAS" | FLVoterFile2016$CountyCode=="CAL" | FLVoterFile2016$CountyCode=="GAD"  
                              | FLVoterFile2016$CountyCode=="LEO" | FLVoterFile2016$CountyCode=="LIB" | FLVoterFile2016$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ReliefRaceTable2016 = table(ReliefVoterFile2016$RaceAdjusted)/nrow(ReliefVoterFile2016)

# GENDER: 0 = Female or other, 1 = Male
ReliefGenderTable2016 = table(ReliefVoterFile2016$gender2)/nrow(ReliefVoterFile2016)

# PARTY
ReliefPartyTable2016 = table(ReliefVoterFile2016$PartyAffiliation)/nrow(ReliefVoterFile2016)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ReliefAgeTable2016 = table(ReliefVoterFile2016$AgeCat2016)/nrow(ReliefVoterFile2016)

##Treatment Counties##
TreatmentCounties2016 <- subset(ReliefVoterFile2016, ReliefVoterFile2016$CountyCode=="BAY" | ReliefVoterFile2016$CountyCode=="FRA" 
                                | ReliefVoterFile2016$CountyCode=="GUL" | ReliefVoterFile2016$CountyCode=="JAC"
                                | ReliefVoterFile2016$CountyCode=="WAS" | ReliefVoterFile2016$CountyCode=="CAL" 
                                | ReliefVoterFile2016$CountyCode=="GAD" | ReliefVoterFile2016$CountyCode=="LIB")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
TreatmentRaceTable2016 = table(TreatmentCounties2016$RaceAdjusted)/nrow(TreatmentCounties2016)

# GENDER: 0 = Female or other, 1 = Male
TreatmentGenderTable2016 = table(TreatmentCounties2016$gender2)/nrow(TreatmentCounties2016)

# PARTY
TreatmentPartyTable2016 = table(TreatmentCounties2016$PartyAffiliation)/nrow(TreatmentCounties2016)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
TreatmentAgeTable2016 = table(TreatmentCounties2016$AgeCat2016)/nrow(TreatmentCounties2016)

##Control Counties##
ControlCounties2016 <- subset(ReliefVoterFile2016, ReliefVoterFile2016$CountyCode=="WAK" | ReliefVoterFile2016$CountyCode=="LEO" 
                              | ReliefVoterFile2016$CountyCode=="HOL" | ReliefVoterFile2016$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ControlRaceTable2016 = table(ControlCounties2016$RaceAdjusted)/nrow(ControlCounties2016)

# GENDER: 0 = Female or other, 1 = Male
ControlGenderTable2016 = table(ControlCounties2016$gender2)/nrow(ControlCounties2016)

# PARTY
ControlPartyTable2016 = table(ControlCounties2016$PartyAffiliation)/nrow(ControlCounties2016)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ControlAgeTable2016 = table(ControlCounties2016$AgeCat2016)/nrow(ControlCounties2016)

#========================#
# RELIEF Voter File 2019 #  
#========================#
# # select only the needed variables

ReliefVoterFile2019 <- subset(FLVoterFile2019, FLVoterFile2019$CountyCode=="BAY" | FLVoterFile2019$CountyCode=="FRA" | FLVoterFile2019$CountyCode=="GUL" 
                              | FLVoterFile2019$CountyCode=="JAC" | FLVoterFile2019$CountyCode=="HOL" | FLVoterFile2019$CountyCode=="WAK" 
                              | FLVoterFile2019$CountyCode=="WAS" | FLVoterFile2019$CountyCode=="CAL" | FLVoterFile2019$CountyCode=="GAD"  
                              | FLVoterFile2019$CountyCode=="LEO" | FLVoterFile2019$CountyCode=="LIB" | FLVoterFile2019$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ReliefRaceTable2019 = table(ReliefVoterFile2019$RaceAdjusted)/nrow(ReliefVoterFile2019)

# GENDER: 0 = Female or other, 1 = Male
ReliefGenderTable2019 = table(ReliefVoterFile2019$gender2)/nrow(ReliefVoterFile2019)

# PARTY
ReliefPartyTable2019 = table(ReliefVoterFile2019$PartyAffiliation)/nrow(ReliefVoterFile2019)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ReliefAgeTable2019 = table(ReliefVoterFile2019$AgeCat2019)/nrow(ReliefVoterFile2019)

##Treatment Counties##
TreatmentCounties2019 <- subset(ReliefVoterFile2019, ReliefVoterFile2019$CountyCode=="BAY" | ReliefVoterFile2019$CountyCode=="FRA" 
                                | ReliefVoterFile2019$CountyCode=="GUL" | ReliefVoterFile2019$CountyCode=="JAC"
                                | ReliefVoterFile2019$CountyCode=="WAS" | ReliefVoterFile2019$CountyCode=="CAL" 
                                | ReliefVoterFile2019$CountyCode=="GAD" | ReliefVoterFile2019$CountyCode=="LIB")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
TreatmentRaceTable2019 = table(TreatmentCounties2019$RaceAdjusted)/nrow(TreatmentCounties2019)

# GENDER: 0 = Female or other, 1 = Male
TreatmentGenderTable2019 = table(TreatmentCounties2019$gender2)/nrow(TreatmentCounties2019)

# PARTY
TreatmentPartyTable2019 = table(TreatmentCounties2019$PartyAffiliation)/nrow(TreatmentCounties2019)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
TreatmentAgeTable2019 = table(TreatmentCounties2019$AgeCat2019)/nrow(TreatmentCounties2019)

##Control Counties##

ControlCounties2019 <- subset(ReliefVoterFile2019, ReliefVoterFile2019$CountyCode=="WAK" | ReliefVoterFile2019$CountyCode=="LEO" 
                              | ReliefVoterFile2019$CountyCode=="HOL" | ReliefVoterFile2019$CountyCode=="WAL")

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
ControlRaceTable2019 = table(ControlCounties2019$RaceAdjusted)/nrow(ControlCounties2019)

# GENDER: 0 = Female or other, 1 = Male
ControlGenderTable2019 = table(ControlCounties2019$gender2)/nrow(ControlCounties2019)

# PARTY
ControlPartyTable2019 = table(ControlCounties2019$PartyAffiliation)/nrow(ControlCounties2019)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
ControlAgeTable2019 = table(ControlCounties2019$AgeCat2019)/nrow(ControlCounties2019)


### Composition of the Electorate in Treatment/Control Counties in 2012  ###
BayVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="BAY")
FranklinVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="FRA")
GulfVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="GUL")
JacksonVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="JAC")
HolmesVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="HOL")
WakullaVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="WAK")
WashingtonVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="WAS")
CalhounVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="CAL")
GadsdenVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="GAD")
LeonVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="LEO")
LibertyVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="LIB")
WaltonVoterFile2012 <- subset(ReliefVoterFile2012, ReliefVoterFile2012$CountyCode=="WAL")

##Bay##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
BayRaceTable2012 = table(BayVoterFile2012$RaceAdjusted)/nrow(BayVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
BayGenderTable2012 = table(BayVoterFile2012$gender2)/nrow(BayVoterFile2012)

# PARTY
BayPartyTable2012 = table(BayVoterFile2012$PartyAffiliation)/nrow(BayVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
BayAgeTable2012 = table(BayVoterFile2012$AgeCat2012)/nrow(BayVoterFile2012)

##Franklin##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
FranklinRaceTable2012 = table(FranklinVoterFile2012$RaceAdjusted)/nrow(FranklinVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
FranklinGenderTable2012 = table(FranklinVoterFile2012$gender2)/nrow(FranklinVoterFile2012)

# PARTY
FranklinPartyTable2012 = table(FranklinVoterFile2012$PartyAffiliation)/nrow(FranklinVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
FranklinAgeTable2012 = table(FranklinVoterFile2012$AgeCat2012)/nrow(FranklinVoterFile2012)

##Gulf##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
GulfRaceTable2012 = table(GulfVoterFile2012$RaceAdjusted)/nrow(GulfVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
GulfGenderTable2012 = table(GulfVoterFile2012$gender2)/nrow(GulfVoterFile2012)

# PARTY
GulfPartyTable2012 = table(GulfVoterFile2012$PartyAffiliation)/nrow(GulfVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
GulfAgeTable2012 = table(GulfVoterFile2012$AgeCat2012)/nrow(GulfVoterFile2012)

##Jackson##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
JacksonRaceTable2012 = table(JacksonVoterFile2012$RaceAdjusted)/nrow(JacksonVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
JacksonGenderTable2012 = table(JacksonVoterFile2012$gender2)/nrow(JacksonVoterFile2012)

# PARTY
JacksonPartyTable2012 = table(JacksonVoterFile2012$PartyAffiliation)/nrow(JacksonVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
JacksonAgeTable2012 = table(JacksonVoterFile2012$AgeCat2012)/nrow(JacksonVoterFile2012)

##Holmes##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
HolmesRaceTable2012 = table(HolmesVoterFile2012$RaceAdjusted)/nrow(HolmesVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
HolmesGenderTable2012 = table(HolmesVoterFile2012$gender2)/nrow(HolmesVoterFile2012)

# PARTY
HolmesPartyTable2012 = table(HolmesVoterFile2012$PartyAffiliation)/nrow(HolmesVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
HolmesAgeTable2012 = table(HolmesVoterFile2012$AgeCat2012)/nrow(HolmesVoterFile2012)

##Wakulla##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
WakullaRaceTable2012 = table(WakullaVoterFile2012$RaceAdjusted)/nrow(WakullaVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
WakullaGenderTable2012 = table(WakullaVoterFile2012$gender2)/nrow(WakullaVoterFile2012)

# PARTY
WakullaPartyTable2012 = table(WakullaVoterFile2012$PartyAffiliation)/nrow(WakullaVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
WakullaAgeTable2012 = table(WakullaVoterFile2012$AgeCat2012)/nrow(WakullaVoterFile2012)

##Washington##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
WashingtonRaceTable2012 = table(WashingtonVoterFile2012$RaceAdjusted)/nrow(WashingtonVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
WashingtonGenderTable2012 = table(WashingtonVoterFile2012$gender2)/nrow(WashingtonVoterFile2012)

# PARTY
WashingtonPartyTable2012 = table(WashingtonVoterFile2012$PartyAffiliation)/nrow(WashingtonVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
WashingtonAgeTable2012 = table(WashingtonVoterFile2012$AgeCat2012)/nrow(WashingtonVoterFile2012)

##Calhoun##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
CalhounRaceTable2012 = table(CalhounVoterFile2012$RaceAdjusted)/nrow(CalhounVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
CalhounGenderTable2012 = table(CalhounVoterFile2012$gender2)/nrow(CalhounVoterFile2012)

# PARTY
CalhounPartyTable2012 = table(CalhounVoterFile2012$PartyAffiliation)/nrow(CalhounVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
CalhounAgeTable2012 = table(CalhounVoterFile2012$AgeCat2012)/nrow(CalhounVoterFile2012)

##Gadsden##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
GadsdenRaceTable2012 = table(GadsdenVoterFile2012$RaceAdjusted)/nrow(GadsdenVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
GadsdenGenderTable2012 = table(GadsdenVoterFile2012$gender2)/nrow(GadsdenVoterFile2012)

# PARTY
GadsdenPartyTable2012 = table(GadsdenVoterFile2012$PartyAffiliation)/nrow(GadsdenVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
GadsdenAgeTable2012 = table(GadsdenVoterFile2012$AgeCat2012)/nrow(GadsdenVoterFile2012)

##Leon##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
LeonRaceTable2012 = table(LeonVoterFile2012$RaceAdjusted)/nrow(LeonVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
LeonGenderTable2012 = table(LeonVoterFile2012$gender2)/nrow(LeonVoterFile2012)

# PARTY
LeonPartyTable2012 = table(LeonVoterFile2012$PartyAffiliation)/nrow(LeonVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
LeonAgeTable2012 = table(LeonVoterFile2012$AgeCat2012)/nrow(LeonVoterFile2012)

##Liberty##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
LibertyRaceTable2012 = table(LibertyVoterFile2012$RaceAdjusted)/nrow(LibertyVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
LibertyGenderTable2012 = table(LibertyVoterFile2012$gender2)/nrow(LibertyVoterFile2012)

# PARTY
LibertyPartyTable2012 = table(LibertyVoterFile2012$PartyAffiliation)/nrow(LibertyVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
LibertyAgeTable2012 = table(LibertyVoterFile2012$AgeCat2012)/nrow(LibertyVoterFile2012)

##Walton##

# RACE: 0 = Other, 1 = Black, 2 = Hispanic, 3 = White
WaltonRaceTable2012 = table(WaltonVoterFile2012$RaceAdjusted)/nrow(WaltonVoterFile2012)

# GENDER: 1 = Male, 0 = Female or other
WaltonGenderTable2012 = table(WaltonVoterFile2012$gender2)/nrow(WaltonVoterFile2012)

# PARTY
WaltonPartyTable2012 = table(WaltonVoterFile2012$PartyAffiliation)/nrow(WaltonVoterFile2012)

# AGE: 1 = 18-29 , 2 = 30-44, 3 = 45-64, 4 = 65+
WaltonAgeTable2012 = table(WaltonVoterFile2012$AgeCat2012)/nrow(WaltonVoterFile2012)

